{% extends 'layout/Gba.html' %}
{% load static %}
{% block title %} 打卡项编辑 {% endblock %}

{% block content %}

    <div class="container">
    <div class="row">
    <div class="panel panel-default col-md-6 col-md-offset-3">
    {% if state == False  %}
  <div class="panel-heading">今日未打卡！</div>
    {% else %}
    <div class="panel-heading">今日已打卡！</div>
    {% endif %}
        <div class="panel-body">

<ul class="list-group" id="ul">

{% if qulist != False %}








<form id="regForm" method="post" novalidate>
            {% csrf_token %}

             {% for key,value in qulist.items %}

 <div class='list-group-item'><div >{{ key }}.{{ value }}

 <label class="radio-inline" style='display:inline-block; float: right;'>
		<input type="radio" name={{ key }} id="optionsRadios3" value=1 >是
	</label>
	<label class="radio-inline" style='display:inline-block; float: right;'>
		<input type="radio" name={{ key }} id="optionsRadios4"  value=2 checked>否
	</label>
</div>
    </div>

    {% endfor %}
    </form>
{% else %}

    <h1>你的单位还为创建打卡问题</h1>

{% endif %}


</ul>


  </div>
</div>
</div>




<div class="row"></div>
        <br>
<div class="row">
                <div class="col-md-1  col-md-offset-8">
                     {% if state == Fasle %}



                            <button type="button" id="btnSubmit" class="btn btn-warning"
			data-container="body" data-toggle="popover" data-placement="top"
			>
		打卡
                         </button>
                    {% else %}
 <button type="button" id="btnSubmit" class="btn btn-success"
			data-container="body" data-toggle="popover" data-placement="top"
			>
		重新打卡
	</button>


                        {% endif %}

                </div>
            </div>

    </div>



</div>

</form>


{% endblock %}








{% block js %}

      <script type="text/javascript">




          $("#btnSubmit").click(function () {   //采集数据


              console.log($('#regForm').serialize());
                   $.ajax({
                     url: "{% url 'web:Gindex' %}",
                     type: "POST",
                     data: $('#regForm').serialize(), // 所有字段数据 + csrf token
                     dataType: "JSON",
                     success: function (res) {
                        if (res.status) {
                          location.href ="{% url 'web:Gindex' %}";
                        } else {

                           $("#btnSubmit").attr("data-content","提交失败！！");
                               $("[data-toggle='popover']").popover();

                        }
                    }
                })
            })

          </script>


{% endblock %}